<template>
  <div class="my-obstruct">
    <el-table :data="tableData"
              border
              :fit="true"
              style="width: 100%">
      <el-table-column label="房屋id"
                       prop="houseId">
      </el-table-column>
      <el-table-column label="地址"
                       prop="address">
      </el-table-column>
      <el-table-column label="租金"
                       prop="price">
      </el-table-column>
      <el-table-column label="租赁人"
                       prop="name">
      </el-table-column>
      <el-table-column label="租赁人身份证号码"
                       prop="userIdCard">
      </el-table-column>
      <el-table-column label="租赁人联系电话"
                       prop="userPhone">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini"
                     type="primary"
                     @click="reportingObstacles(scope.$index, scope.row)">报障</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-box">
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page="pagination.currentPage"
        :page-size="pagination.pageSize"
        layout="total, prev, pager, next"
        :total="pagination.total">
      </el-pagination>
    </div>
    <el-dialog title="修改信息"
               :visible.sync="dialogVisible"
               width="40%"
               :before-close="handleClose">
      <el-form :model="ruleForm" :rules="rules"
                ref="ruleForm" label-width="100px"
                class="demo-ruleForm">
        <el-form-item label="房屋id" prop="id">
          <el-input v-model="ruleForm.id"></el-input>
        </el-form-item>
        <el-form-item label="地址" prop="address">
          <el-input v-model="ruleForm.address"></el-input>
        </el-form-item>
        <el-form-item label="租客姓名" prop="renter">
          <el-input v-model="ruleForm.renter"></el-input>
        </el-form-item>
        <el-form-item label="报障日期" prop="date">
          <el-date-picker type="date" placeholder="选择日期" v-model="ruleForm.date" style="width: 100%;"></el-date-picker>
        </el-form-item>
        <el-form-item label="报障内容" prop="content">
          <el-input type="textarea" v-model="ruleForm.content"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer"
            class="dialog-footer">
        <el-button @click="handleClose()">取消</el-button>
        <el-button type="primary"
                   @click="submit()">提交</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script lang="js">
import axios from "axios";

export default {
  name: 'myobstruct',
  data(){
    return {
      tableData: [],
        ruleForm: {
          id:'c3',
          address: '上海市普陀区金沙江路 1518 弄',
          renter: 'xxx',
          date: '2023-12-15',
          content: '13245689874'
        },
        rules: {
          id: [
            { required: true, message: '请输入id', trigger: 'blur' },
            { min: 3, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' }
          ],
          address: [
            { required: true, message: '请选择活动区域', trigger: 'change' }
          ],
          renter: [
            { required: true, message: '请选择活动区域', trigger: 'change' }
          ],
          date: [
            { required: true, message: '请选择活动区域', trigger: 'change' }
          ],
          content: [
            { required: true, message: '请选择活动区域', trigger: 'change' }
          ]
        },
        dialogVisible: false,
      pagination: {//分页相关模型数据
        currentPage: 1,//当前页码
        pageSize: 10,//每页显示的记录数
        total: 0,//总记录数
        type:"",
        name:"",
        description:"",
      }
    }
  },
  created() {
    this.getAll()
  },
  methods: {
    getAll: function (){
      axios.get("/wrong/"+this.pagination.currentPage).then((res)=>{
        if (res.data.code === 1){
          this.tableData = res.data.data.records
          this.pagination.currentPage = res.data.data.current
          this.pagination.total = res.data.data.total
          this.pagination.pageSize = res.data.data.size
        }
      })
    },
    edit(index, row) {
        //  访问接口

        this.$message({
          message: '已经处理',
          type: 'success'
        });
      },
      reportingObstacles(){
        this.dialogVisible = true;
      },
      handleClose(){
        this.dialogVisible = false
      },
      submit() {
        this.$router.push({path:'/processobstruct'})
      },
    //切换页码
    handleCurrentChange(currentPage) {
      this.pagination.currentPage = currentPage;
      this.getAll();
    },
    }
}
</script>
<style lang="scss" scoped>
</style>
